<?php

defined('ACC')||exit('Access Denied');

class AttrModel extends Model{
	
	/* 获取栏目列表 */
	public function get_cat_list(){
		$sql = 'select cat_id, cat_name from goods_type order by cat_id asc';
		return $this->db->getAll($sql);
	}
	
	/* 获取一行栏目信息 */
	public function get_cat_row($cat_id){
		$sql = 'select cat_id, cat_name from goods_type where cat_id = ' . $cat_id;
		return $this->db->getRow($sql);
	}
	
	/* 获取栏目名 */
	public function get_cat_name($cat_id){
		$sql = 'select cat_name from goods_type where cat_id = ' . $cat_id;
		return $this->db->getOne($sql);
	}
	
	/* 获取栏目下所有属性列表 */
	public function get_attr_list($cat_id){
		$sql = 'select attr_id, attr_name, attr_input_type, attr_values from attribute where cat_id = ' . $cat_id;
		return $this->db->getAll($sql);
	}
	
	/* 获取所有属性 */
	public function get_attr_all(){
		$sql = 'select attr_id, attr_name, attr_input_type, attr_values from attribute';
		return $this->db->getAll($sql);
	}
	
	/* 删除一行属性 */
	public function delete_attr($attr_id){
		$sql = 'delete from attribute where attr_id = ' . $attr_id;
		return $this->db->query($sql);
	}
	
	/* 获取一行属性 */
	public function get_attr_row($attr_id){
		$sql = 'select attr_id, cat_id, attr_name, attr_input_type, attr_type, attr_values, attr_index, is_linked from attribute where attr_id = ' . $attr_id;
		return $this->db->getRow($sql);
	}
	
	
}











